package chixing.day06.homework;

/**
 * 属性：loanAmount（贷款金额）
 * 构造函数：通过 super 初始化姓名和余额，同时设置贷款金额
 * 方法：isEligibleForMoreLoan()：
 * 如果 loanAmount 小于账户余额的 2 倍，返回 true，否则返回 false
 */
public class LoanCustomer extends Customer{
    private double loanAmount;

    public LoanCustomer(){}
    public LoanCustomer(double loanAmount) {
        this.loanAmount = loanAmount;
    }

    public LoanCustomer(String custName, double custBalance, double loanAmount) {
        super(custName, custBalance);
        this.loanAmount = loanAmount;
    }

    /**
     * 如果 loanAmount 小于账户余额的 2 倍，
     * @return  返回 true，否则返回 false
     */
    public boolean isEligibleForMoreLoan(){
        if (loanAmount < this.getCustBalance() * 2)
            return true;
        return false;
    }

    public double getLoanAmount() {
        return loanAmount;
    }

    public void setLoanAmount(double loanAmount) {
        this.loanAmount = loanAmount;
    }

    @Override
    public String toString() {
        return super.toString() +
                ",loanAmount=" + loanAmount +",";
    }
}
